//加载公共样式
require('../../assets/css/index.less')


let dom = require('../../utils/dom')
const request = require('../../utils/request')

//字体图标
require('../../assets/fonts/iconfont.css')
//加载自己的样式
require('./circle.less')


window.onload = () => {
    //底部
    dom.Bmenu('circle')
    let CircleContent = document.querySelector('#CircleContent')

    function getCircleList() {
        request.get('http://fitness.h5.itsource.cn:3701/api/circles/opinionList').then(res => {
            console.log(res);
            let { errno, data } = res.data
            if (errno == 0) {
                localStorage.getItem('userinfo')
                data.map(v => {
                    console.log(v);
                    CircleContent.innerHTML +=
                        `
                        <div class="infor df">
                        <img src="#" alt="">
                        <div class="username">
                            <p class="font16" style="margin-bottom:5px;">${v.id}</p>
                            <p class="font12"></p>
                        </div>
                        </div>
                        <p class="words font14">
                            ${v.content}
                        </p>
                        <div class="photos df">
                            <img src="${v.imgUrls}" alt="">
                        </div>
                    `
                })
            }
        })
    }
    getCircleList()

    //获取数据
    function getCourselist() {
        // console.log(111);
        request.get('http://fitness.h5.itsource.cn:3701/api/train/courseList').then(res => {
            console.log('最新课程', res)
            let { errno, data } = res.data;
            if (errno == 0) {
                data.map((v, i) => {
                    // console.log(v,i)
                    if (i == 0) {
                        rander('#course', v)
                    }
                })
            }
        })
    }
    getCourselist()

    //渲染数据
    function rander(obj, data) {
        document.querySelector(obj).innerHTML += `
        <a href="course.html?id=${data.courseId}">
        <img src=${'http://fitness.h5.itsource.cn:3701' + data.imgurl} alt="">
        <div class="couse-details">
            <h3 class="font16">${data.name}</h3>
            <p class="font12">${data.desc}</p>
        </div>
        </a>
        `
    }

}


